<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const str = "abcDEFG";

      // 保存字符
      let newStr = "";
      // 遍历字符
      for (let i = 0; i < str.length; i++) {
        if (i % 2 === 0) {
          newStr += str[i].toLowerCase();
        } else {
          newStr += str[i].toUpperCase();
        }
      }
      console.log(newStr);

      /* str = {
        0: "a",
        1: "b",
        2: "c",
        3: "d",
        4: "e",
        5: "f",
        6: "g",
        length: 7
      }; */
    </script>
  </body>
</html>
